<template>
<div class="me-login">
	<!-- <header class="login-bar bar bar-nav">
		<span class="icon-login icon icon-left" v-on:click="back"></span>
  		<h3 class='title title-login'>会员登录</h3>
	</header> -->
	<themeHeader title="会员登录"></themeHeader>
	<div class="content login-content1">
		<div class="list-block login-content">
			<ul class="login-ul">
				<li>
			        <div class="item-content login-item-content">
			          <div class="item-media"><i class="icon icon-form-name"></i></div>
			          <div class="item-inner">
			            <div class="item-input">
			              <input type="text" id="txt" placeholder="用户名/手机/邮箱">
			            </div>
			          </div>
			        </div>
		      	</li>
		      	<li>
			        <div class="item-content login-item-content">
			          <div class="item-media"><i class="icon icon-form-name"></i></div>
			          <div class="item-inner">
			            <div class="item-input">
			              <input type="password" class="pwd" placeholder="密码">
			            </div>
			          </div>
			        </div>
		      	</li>
			</ul>
		</div>
		<div>
			<a class="forget" href="###">忘记密码？</a>
		</div>
		<div class="login-button row">
			<p class="col-50 login-button-p "><span class="button button-success greenbg btnde">登录</span></p>
			<p class="col-50 login-button-p"><router-link to="/zc" class="button button-success greenbg">立即注册</router-link></p>
		</div>
		<div class="login-hr">
			<hr>
			<p>合作账号登录</p>
		</div>
	</div>
</div>
</template>
<style type="text/css">

     .login-content1{
     	background: #f8f8f8;
     }
	.me-login .login-content{
		margin: 0.5rem 0;
	}
	.bar .icon-login{
		color: green;
		font-weight: bold;
	}
	.login-ul{
		border:0.05rem solid #ddd;
		border-left: none;
		border-right: none;
	}
	.list-block .login-item-content{
		padding-left: 0;
	}
	.list-block .login-item-inner{
		margin-left: 0;
	}
	.title-login{
		position: absolute;
		top: 0;
	}
	.forget{
		color: green;
	}
	.login-button-p{
		padding: 2rem 0 3rem 0;
		text-align: center;
	}
	.login-button-p .greenbg{
		display: inline-block;
		width: 6rem;
		height: 1.5rem;
		border-color: skyblue;
		color: green;
	}
	.login-button-p .greenbg{
		background: green;
		color: white;
	}
	.login-hr{
		text-align: center;
		padding: 0 1.5rem;
		position: relative;
	}
	.login-hr hr{
		position: absolute;
		border: none;
		border-top: 0.02rem solid #ddd;
	}
	.login-hr p{
		position: absolute;
		width: 10rem;
		padding: 0 1rem;
		color: #999;
		font-size: 0.7rem;
	}
</style>
<script type="text/javascript">
import ThemeHeader from "../pages/home/component/themeHeader.vue";
	export default {
		components:{
			ThemeHeader,
		},
		methods:{
			back:function(){
			},
			getAddFn:function(){
				$.ajax({
					type:"post",
					url:"http://localhost:8088/shop2/add-addressp.php",
					data:{type:"get"},
					dataType:"json",
					success:function(data){
						data.data.forEach(function(i){ 	
							 	if(i["defaultAdd"]==1){
							 		var addObj={id:i["id"],name:i["name"],phone:i["phone"],phone2:i["phone2"],place:i["place"],defaultAdd:i["defaultAdd"]};
							 		var str=JSON.stringify(addObj);
                   					 localStorage.setItem("defaultAddress",str);
							 	}
							 	
						 });
					}
				});
			}
		},
		mounted(){
			$(".loginNone").hide();
			var $name=$("#txt");//用户名
			var $pwd=$(".pwd");
			var $btn=$(".btnde");
			var bol=false;//是否存在用户名(不存在)
			$btn.on("click",function () {
				$.ajax({
		            type:"post",
		            url:"http://localhost:8088/shop2/zhuce.php",
					data:{type:"check",name:$name.val(),pwd:$pwd.eq(0).val()},
					dataType:"json",
					success:function (data) {
				        if (data.bol){
						    alert("登录成功");
						    setCookie("userName",$name.val(),1);
						    _this.getAddFn();
						  	_this.$router.push("/home");

						}else {
						    alert("登录失败");
						}
						
		            }
				});
		    });

		    var _this=this;
				
		},
		  beforeDestroy: function () {
		  		$(".loginNone").show();
		  }

	}
</script>
